package com.bawei.room

import android.content.Context
import androidx.room.Room
import com.bawei.room.db.AppDataBase

/**
 * Author: Jason Zhang
 * Date: 2025/1/14
 * Desc: 数据库工具
 */
object DBUtil {

    private lateinit var dataBase: AppDataBase

    /**
     * 初始化数据库
     */
    fun initRoomDB(context: Context){
        dataBase = Room.databaseBuilder(context, AppDataBase::class.java, "video.db").build()
    }


    /**
     * 获取数据库实例
     */
    fun getDataBase(): AppDataBase {
        if (dataBase == null){
            throw RuntimeException("DataBase not initialized")
        }
        return dataBase
    }

}